﻿using Microsoft.Extensions.DependencyInjection;
using SBlogCore.Common.DispatchProxyIn;
using SBlogCore.Common.RemoteRequest.Proxys;

namespace SBlogCore.Common.RemoteRequest.Extensions
{
    public static class RemoteRequestServiceExtensions
    {
        /// <summary>
        /// 注册远程请求
        /// </summary>
        /// <param name="services"></param>
        /// <param name="configure"></param>
        /// <returns></returns>
        public static IServiceCollection AddRemoteRequest(this IServiceCollection services, Action<IServiceCollection>? configure = null)
        {
            // 注册远程请求代理接口
            services.AddDispatchProxyService<IHttpDispatchProxy, HttpDispatchProxy>();
            // 注册默认请求客户端
            services.AddHttpClient();
            // 注册其他客户端
            configure?.Invoke(services);
            return services;
        }
    }
}
